package org.example.configuration;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
//分页查询的配置类
//@Configuration
//public class PageConfiguration {
// @Bean
//   public PaginationInnerInterceptor paginationInterceptor() {
//     return new PaginationInnerInterceptor();
// }
//}
//分页查询的配置类 上面仅限于分页查询的配置，且与不同的mp版本搭配可能会得不到所有的查询记录数，建议使用下面这个配置类分页插件
@Configuration
public class PageConfiguration {
    @Bean
    public MybatisPlusInterceptor paginationInterceptor(){
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor(DbType.MYSQL);
        interceptor.addInnerInterceptor(paginationInnerInterceptor);
        return interceptor;
    }
}
